package com.jyhs.maven.controller;

import com.alibaba.fastjson.JSON;
import com.jyhs.maven.service.MenuService;
import com.jyhs.maven.service.impl.MenuServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;



@Controller
@RequestMapping("/menu")
public class MenuContoller2 {

    @Autowired
    private MenuService menuService;

    @GetMapping ("/t03/add")
    public String add(@RequestParam(value = "name2",required = true) String name,
                      @RequestParam(value = "age",defaultValue = "18") String age) {
        System.out.println("name:" + name);
        System.out.println("age:" + age);
        System.out.println("add");
        return "add";
    }


//    @GetMapping (value = "selectList",produces = "application/json;charset=UTF-8")
    @GetMapping (value = "selectList")
    @ResponseBody
    public String selectList() {
        System.out.println("selectList");
        return JSON.toJSONString(menuService.selectAll());
    }


}
